package com.mine.photohandler.activity;


import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.GridView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.mine.photohandler.R;
import com.mine.photohandler.adapter.ImageFileAdapter;
import com.mine.photohandler.base.BaseAppCompatActivity;
import com.mine.photohandler.util.Bimp;
import com.mine.photohandler.util.ImageBucket;

import java.util.ArrayList;
import java.util.List;


/**
 * 这个类主要是用来进行显示包含图片的文件夹
 *
 */
public class ImageFile extends BaseAppCompatActivity {
	private TextView mTv_top_title;
	private GridView mGv_file;
	private RelativeLayout mRl_back;

	private ImageFileAdapter mAdapter;
	private List<ImageBucket> contentList = new ArrayList<>();

	@Override
	protected int contentView() {
		return R.layout.plugin_activity_imagefile;
	}

	@Override
	protected void initViews() {
		setStatusBar(Color.BLACK);
		mTv_top_title = findViewById(R.id.tv_top_title);
		mGv_file = findViewById(R.id.gv_file);
		mRl_back = findViewById(R.id.rl_back);

		contentList = Bimp.helper.getImagesBucketList(false);
		mAdapter = new ImageFileAdapter(this,false, R.layout.plugin_camera_select_folder);
		mGv_file.setAdapter(mAdapter);
		mAdapter.setDatas(contentList);

		mTv_top_title.setText(getString(R.string.album));

	}

	@Override
	protected void initEvents() {
		mTv_top_title.setText(R.string.photo);
		mRl_back.setVisibility(View.GONE);
		findViewById(R.id.rl_right).setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View view) {
				finish();
			}
		});

		mGv_file.setOnItemClickListener(new AdapterView.OnItemClickListener() {
			@Override
			public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) {
				Bundle bundle = new Bundle();
				bundle.putString("folderName", contentList.get(position).bucketName);
				bundle.putInt("folderName_pos", position);
				startActivity(ShowAllPhoto.class,true,bundle);
			}
		});


	}
}
